package com.share.cloudStorage.advice;

import com.share.cloudStorage.model.Result;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: javaKing
 * @Date: 2024/12/09/16:03
 * @Description:
 */
@RestControllerAdvice
public class ErrorControllerAdvice {
    @ExceptionHandler(value = Exception.class)
    public Result serviceExceptionHandler(Exception exception, HttpServletResponse response) {
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        exception.printStackTrace();
        return Result.fail(exception.getMessage(), null);
    }
}